<template>
  <data-table ref="pagingTable" :options="options" :list-query="listQuery">
    <template #filter-content>
      <dic-catalog-tree v-model="listQuery.params.catId" dic-code="repo_catalog" width="200" title="题库分类查询" class="filter-item" style="margin-top: 3px" /> <el-input v-model="listQuery.params.title" size="small" placeholder="搜索题库名称" style="width: 200px;" class="filter-item" />
      <div class="file-item" style="display: inline-block">
        <div style="display: flex; align-items: center; padding-left: 10px">
          <el-checkbox v-model="listQuery.params.forExam" label="用于考试" /> <el-checkbox v-model="listQuery.params.forTrain" label="用于训练" />
        </div>
      </div>
    </template>
    <template #data-columns>
      <el-table-column label="题库名称" prop="title" show-overflow-tooltip>
        <template v-slot="scope">
          <detail-link :id="scope.row.id" :title="scope.row.title" to="RepoUpdate" permission="repo:update" />
        </template>
      </el-table-column> <el-table-column label="开放类型" width="100px" prop="openType_dictText" align="center" /> <el-table-column label="题库分类" prop="catId_dictText" align="center" width="120px" show-overflow-tooltip /> <el-table-column label="根知识点" prop="pointCode_dictText" align="center" width="120px" show-overflow-tooltip /> <el-table-column label="总题数" align="center" prop="quCount" width="100px" /> <el-table-column label="客观题数" align="center" prop="objCount" width="100px" /> <el-table-column label="主观题数" align="center" prop="subjCount" width="100px" /> <el-table-column label="用于考试" align="center" width="90px">
        <template v-slot="scope">
          <span v-if="scope.row.forExam" style="color: #1aac1a">是</span> <span v-else style="color: #ff3333">否</span>
        </template>
      </el-table-column> <el-table-column label="用于训练" align="center" width="90px">
        <template v-slot="scope">
          <span v-if="scope.row.forTrain" style="color: #1aac1a">是</span> <span v-else style="color: #ff3333">否</span>
        </template>
      </el-table-column> <el-table-column label="创建人" align="center" prop="createBy_dictText" width="120px" /> <el-table-column label="创建时间" align="center" prop="createTime" width="160px" /> <el-table-column label="操作" fixed="right" align="center" width="200px">
        <template v-slot="scope">
          <router-link v-permission="['qu:list']" :to="{ name: 'QuList', query: { repoId: scope.row.id }}" style="margin-left: 10px">
            <el-link type="primary" icon="el-icon-document">
              试题管理
            </el-link>
          </router-link> <router-link :to="{ name: 'RepoAnalysis', query: { repoId: scope.row.id }}" style="margin-left: 10px">
            <el-link type="primary" icon="el-icon-pie-chart">
              题库分析
            </el-link>
          </router-link>
        </template>
      </el-table-column>
    </template>
  </data-table>
</template>
<script>
import permission from '@/directive/permission/index.js'
import { mapGetters } from 'vuex'

export default {
  name: 'RepoList',
  directives: { permission },
  data() {
    return {

      listQuery: {
        current: 1,
        size: 10,
        params: {
          title: ''
        }
      },

      forExam: false,
      forTrain: false,

      options: {

        // 可批量操作
        multi: true,

        add: {
          enable: true,
          permission: 'repo:add',
          router: { name: 'RepoAdd' }
        },
        edit: {
          enable: true,
          permission: 'repo:update',
          router: { name: 'RepoUpdate', params: { id: '$id' }}
        },
        delete: {
          enable: true,
          permission: 'repo:delete',
          url: '/api/repo/delete'
        },

        // 列表请求URL
        listUrl: '/api/repo/paging'
      }
    }
  },

  computed: {
    ...mapGetters([
      'siteData'
    ])
  },

  activated() {
    this.$refs.pagingTable.refresh()
  }
}
</script>
